package day16.problem3;

//DNA序列
//https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a?tpId=37&tqId=21286&ru=/exam/oj

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int k = in.nextInt();
        int n = s.length();
        int count = 0, m = 0, index = 0;
        // System.out.println(n);
        for (int i = 0, j = 0; j < n; j++) {
            if (s.charAt(j) == 'C' || s.charAt(j) == 'G') {
                count++;
            }
            if (j - i + 1 > k) {
                if (s.charAt(i) == 'G' || s.charAt(i) == 'C') {
                    count--;
                }
                i++;
            }
            if (count > m) {
                m = count;
                index = i;
            }
        }
        System.out.println(s.substring(index, index + k));
    }
}